#include <stdio.h>
#include <stdlib.h>

//指向结构体变量的指针,执行结构体数组额指针

struct student
{
    int num;
    char *name;
    char sex;
    float score;
} stu1 = {102, "张三", 'M', 90.5}, *pstu, stus[] = {{102, "张三", 'M', 90.5}, {102, "张三", 'M', 90.5}, {102, "张三", 'M', 90.5}, {102, "张三", 'M', 90.5}, {102, "张三", 'M', 90.5}};

int main()
{
    printf("\n\n========================================================================\n\n");
    printf("stu1:num=%d,name=%s,sex=%c,score=%f\n", stu1.num, stu1.name, stu1.sex, stu1.score);
    pstu = &stu1;
    printf("pstu:num=%d,name=%s,sex=%c,score=%f\n", (*pstu).num, (*pstu).name, (*pstu).sex, (*pstu).score);
    printf("pstu:num=%d,name=%s,sex=%c,score=%f\n", pstu->num, pstu->name, pstu->sex, pstu->score);
    stu1.name = "李四"; //注意pstu是指向stu1的指针，所以改变stu1内容，pstu也会改变
    printf("stu1:num=%d,name=%s,sex=%c,score=%f\n", stu1.num, stu1.name, stu1.sex, stu1.score);
    printf("pstu:num=%d,name=%s,sex=%c,score=%f\n", pstu->num, pstu->name, pstu->sex, pstu->score);

    struct student *ps;
    for (ps = stus; ps < stus + 5; ps++)
    {
        printf("pstu:num=%d,name=%s,sex=%c,score=%f\n", ps->num, ps->name, ps->sex, ps->score);
    }

    printf("\n\n========================================================================\n\n");
    return 0;
}